package com.its.oa.system.user.action;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class UserInterceptor extends AbstractInterceptor implements SessionAware{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Map<String,Object> session;

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		UserAction userAction = (UserAction) invocation.getAction();
		session = ActionContext.getContext().getSession();
		userAction.setActionName(invocation.getProxy().getActionName()+".action");
		if(session.get("userInfo")==null)
			return Action.ERROR;
		else
			return invocation.invoke();
	}

	public void setSession(Map<String, Object> session) {
		this.session = session;		
	}

	public String catchCurrentURL() {
		// TODO Auto-generated method stub
		return null;
	}

}
